<template>
  <!--消息-->
  <!--父菜单-->
  <el-menu
    class="el-menu-demo"
    mode="horizontal"
    @select="handleSelect"
    background-color="transparent"
    text-color="#fff">
    <!--子容器-->
    <el-submenu index="1">
      <!--容器的内容-->
      <template slot="title">
        <el-badge :value="$store.state.uncheckCommentDataForNavMenu.total" :max="99" class="item">
          <b class="iconfont icon-youjian2"></b>
        </el-badge>
      </template>
      <!--容器的下拉菜单-->
      <el-menu-item v-for="item in $store.state.uncheckCommentDataForNavMenu.list" :key="item.id">
        <!--待回复审核的消息-->
        <div class="audit-item">
          <!--待审核回复的头像-->
          <div class="audit-item-left">
            <img :src="item.authorPhoto" alt="">
          </div>
          <!--待审核回复的内容-->
          <div class="audit-item-right">
            <div class="audit-item-right-top">
              <span class="reply-item">
                <span class="reply-name">{{item.authorName}}</span>
                <b>在文章</b>
                <div class="reply-type">{{item.article}}</div>
                <b>中发表了评论</b>
              </span>
            </div>
            <div class="audit-item-right-bottom">
              <span class="handler-message">点击查看&审核</span>
              <span class="reply-time">{{item.commentTime}}</span>
            </div>
          </div>
        </div>
      </el-menu-item>
      <!--立即处理按钮-->
      <el-menu-item class="handlerItem">
        <div class="handlerBtn" v-if="$store.state.uncheckCommentDataForNavMenu.total != 0">立即进行处理 >>></div>
        <div class="handlerBtn" v-else>没有待审核的评论</div>
      </el-menu-item>
    </el-submenu>
  </el-menu>
</template>

<script>

  export default {
    name: "NavMenu",
    methods: {
      /**
       * 点击navMenu的下拉菜单时调用的方法
       */
      handleSelect() {
        if (this.$route.path !== "/comment") {
          this.$router.push("/dashboard/comment");
        }
      },
    },
    mounted() {
      // 从vuex中获取未审核的评论信息
      this.$store.commit("getCommentForUnchecked");
    }
  }
</script>

<style scoped>
  /*设置图标的样式*/
  b {
    height: 100%;
    font-size: 24px;
    vertical-align: middle;
    margin-right: 25px;
    font-weight: normal;
    transition: all 200ms;
  }

  b:hover {
    color: #66b1ff;
  }

  /*去除navmenu上的箭头*/
  .el-submenu__icon-arrow,.el-icon-arrow-down {
    display: none !important;
  }

  /*设置下拉框中li的样式*/
  .el-menu-item {
    background-color: #fff !important;
    color: #409EFF !important;
    height: 70px !important;
    line-height: 70px !important;
    padding: 5px 10px !important;
    text-align: center;
    transition: none !important;
  }


  /*设置下拉框中最后一个li的样式，即立即处理按钮的样式*/
  .handlerItem {
    color: #fff;
    height: 50px !important;
    line-height: 50px !important;
    transition: none !important;
  }
  .handlerItem:hover {
    background-color: #fff !important;
    /*border-radius: 5px;*/
  }
  .handlerItem .handlerBtn {
    width: 100%;
    height: 40px;
    background-color: #eee;
    color: #666;
    font-weight: bold;
    line-height: 40px;
    transition: all 200ms;
    border-radius: 5px;
  }

  .handlerItem .handlerBtn:hover {
    font-size: 16px;
  }

  .audit-item {
    border-radius: 5px;
  }

  /*去除li对立面内容的padding*/
  .el-menu--horizontal .el-menu .el-menu-item, .el-menu--horizontal .el-menu .el-submenu__title {
    padding: 0
  }


  /*设置header右侧的navbar的背景颜色为透明色*/
  .el-submenu__title {
    background-color: transparent !important;
  }
  .el-submenu__title:hover  {
    font-weight: bold;
  }
  .el-submenu__title i {
    color: #fff !important;
  }
  .el-submenu__title i:first-child {
    font-size: 24px;
  }

  .el-menu--popup {
    background-color: #fff !important;
    display: inline-block;
  }
  .el-menu {
    display: inline-block !important;
    border-bottom: none !important;
  }

  /*el-popper*/

  /*设置待审核信息的样式*/
  .audit-item {
    background-color: #eee;
    padding: 0;
    overflow: hidden;
    height: 100%;
    transition: all 200ms;
  }
  .audit-item:hover {
    /*font-weight: bold;*/
    transform: scale(1.02, 1.02);
  }
  .audit-item .audit-item-left>img {
    float: left;
    width: 50px;
    line-height: 70px;
    vertical-align: middle;
    margin-left: 5px;
    margin-top: 5px;
  }
  .audit-item .audit-item-right {
    padding: 0px 20px 0px 70px;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
  }
  .reply-item b {
    font-size: 14px !important;
    display: inline-block;
    vertical-align: middle;
    margin-right: 0;
  }
  .reply-item span {

  }
  .reply-time {
    display: inline-block;
    height: 30px;
    line-height: 30px;
    color: #666;
  }

  .reply-type {
    display: inline-block;
    color: #409EFF;
  }
  .reply-name {
    font-weight: bold;
    margin-right: 5px;
  }
  .audit-item-right-top {
    display: flex;
    justify-content: space-between;
    height: 30px;
    line-height: 30px;
    color: #666;
  }
  .audit-item-right-bottom {
    display: flex;
    justify-content: space-between;
  }
  .handler-message {
    display: inline-block;
    height: 30px;
    line-height: 30px;
    color: #666;
  }
  .handler-message:hover {
    text-decoration: underline;
  }
</style>

<style>
  .el-menu--horizontal {
    z-index: 10000 !important;
  }
</style>